/*$(document).ready(function() {*/

    function login() {
        $.layer({
            type: 2,
            title: '用户登录',
            maxmin: true,
            shadeClose: true, //开启点击遮罩关闭层
            area: ['780px', '650px'],
            offset: ['100px', ''],
            iframe: {src: '../login/index.html'}
        });
    }

    function register() {
        $.layer({
            type: 2,
            title: '用户注册',
            maxmin: true,
            shadeClose: true, //开启点击遮罩关闭层
            area: ['780px', '650px'],
            offset: ['10px', ''],
            iframe: {src: '../login/index.html'}
        });
    }

//商品展开
    function listChange(id) {
        $("#" + id).toggle();
    }

    function lazyload() {
        alert("bigin........")
        /*首页  渲染商品展示页面*/
        /*获取所有商品*/
        $.ajax({
            url: '/display/getGoods',
            data: {"keyword":"",type:""},
            type: "GET",
            dataType: "json",
            success: function (data) {
                alert("return > 所有 " + data);
                var i=1;
                $.each(data.data.list, function (idx, obj) {
                    //显示4条数据
                    if(i==5)
                    {
                        return false;
                    }
                    var img = document.createElement("img");
                    img.setAttribute("alt","没有数据");
                    var td = document.createElement("td");
                    td.setAttribute("style","background:#f3f3f3;border:none");
                    //选择商品高亮显示控制
                    img.onmouseover = function(){ changePicin(td);}
                    img.onmouseout = function(){changePicout(td);}

                    //图片多张
                    var imageData = obj.image_urls;
                    var imagesArray = new Array;
                    imagesArray = imageData.split("#");

                    img.src = "/upload/image/"+imagesArray[0];
                    td.appendChild(img);
                    $("#advice_tr5").append(td);
                    var p1 = document.createElement("p");
                    p1.setAttribute("class","prolist_name");
                    var p2 = document.createElement("p");
                    var a = document.createElement("a");
                    a.setAttribute("href","#");
                    a.innerHTML = obj.name;
                    a.onclick = function(){goodDetail(obj.id);}
                    p1.appendChild(a);
                    var span = document.createElement("span");
                    span.setAttribute("class","money");
                    span.innerHTML = "￥"+obj.price;
                    p2.appendChild(span);
                    td.appendChild(p1).appendChild(p2);
                    $("#advice_tr5").append(td);
                    i++;
                });
            }

        });
        //鼠标移入商品，商品选中高亮显示
        function changePicin(a){
            a.style.border="red 1px solid";
        }
        //鼠标移出商品，商品去除选中高亮显示
        function changePicout(a){
            a.style.border="none";
        }

        /*获取商品详细信息*/

        function goodDetail(id){
            $.ajax({
                url: '/business/goodsDetail',
                data: {"id":id},
                type: "GET",
                dataType: "json",
                success: function (data) {
                    alert("id > " + id + " > " + data.msg);
                    var sessionStorage=window.sessionStorage;
                    sessionStorage.setItem("goodDetail",JSON.stringify(data));
                    location.href = "/font/user/goodsDetail.html";
                }
                });
        }
        /*获取 推荐-4 商品*/

        $.ajax({
            url: '/display/getGoods',
            data: {"keyword":"",type:"4"},
            type: "GET",
            dataType: "json",
            success: function (data) {
                alert("return > 推荐 >" + data.data.count);
                var i=1;
                $.each(data.data.list, function (idx, obj) {
                    //显示4条数据
                    if(i==5)
                    {
                        return false;
                    }
                    var img = document.createElement("img");
                    img.setAttribute("alt","没有数据");
                    var td = document.createElement("td");
                    td.setAttribute("style","background:#f3f3f3;border:none");
                    //选择商品高亮显示控制
                    img.onmouseover = function(){ changePicin(td);}
                    img.onmouseout = function(){changePicout(td);}
                    //图片多张
                    var imageData = obj.image_urls;
                    var imagesArray = new Array;
                    imagesArray = imageData.split("#");

                    img.src = "/upload/image/"+imagesArray[0];
                    td.appendChild(img);
                    $("#advice_tr4").append(td);
                    var p1 = document.createElement("p");
                    p1.setAttribute("class","prolist_name");
                    var p2 = document.createElement("p");
                    var a = document.createElement("a");
                    a.setAttribute("href","#");
                    a.innerHTML = obj.name;
                    a.onclick = function(){goodDetail(obj.id);}
                    p1.appendChild(a);
                    var span = document.createElement("span");
                    span.setAttribute("class","money");
                    span.innerHTML = "￥"+obj.price;
                    p2.appendChild(span);
                    td.appendChild(p1).appendChild(p2);
                    $("#advice_tr4").append(td);
                    i++;
                });

             }
        });
        /*获取 热卖-3 商品*/
        $.ajax({
            url: '/display/getGoods',
            data: {"keyword":"",type:"3"},
            type: "GET",
            dataType: "json",
            success: function (data) {
                alert("return > 热卖 >  " + data.data.count);
                var i=1;
                $.each(data.data.list, function (idx, obj) {
                    //显示4条数据
                    if(i==5)
                    {
                        return false;
                    }
                    var img = document.createElement("img");
                    img.setAttribute("alt","没有数据");
                    var td = document.createElement("td");
                    td.setAttribute("style","background:#f3f3f3;border:none");
                    //选择商品高亮显示控制
                    img.onmouseover = function(){ changePicin(td);}
                    img.onmouseout = function(){changePicout(td);}
                    //图片多张
                    var imageData = obj.image_urls;
                    var imagesArray = new Array;
                    imagesArray = imageData.split("#");

                    img.src = "/upload/image/"+imagesArray[0];
                    td.appendChild(img);
                    $("#advice_tr3").append(td);
                    var p1 = document.createElement("p");
                    p1.setAttribute("class","prolist_name");
                    var p2 = document.createElement("p");
                    var a = document.createElement("a");
                    a.setAttribute("href","#");
                    a.innerHTML = obj.name;
                    a.onclick = function(){goodDetail(obj.id);}
                    p1.appendChild(a);
                    var span = document.createElement("span");
                    span.setAttribute("class","money");
                    span.innerHTML = "￥"+obj.price;
                    p2.appendChild(span);
                    td.appendChild(p1).appendChild(p2);
                    $("#advice_tr3").append(td);
                    i++;
                });
            }
        });

        /*获取 特卖-2 商品*/
        $.ajax({
            url: '/display/getGoods',
            data: {"keyword":"",type:"2"},
            type: "GET",
            dataType: "json",
            success: function (data) {
                alert("return > 特卖 > " + data.data.count);

                var i=1;
                $.each(data.data.list, function (idx, obj) {
                    //显示4条数据
                    if(i==5)
                    {
                        return false;
                    }
                    var img = document.createElement("img");
                    img.setAttribute("alt","没有数据");
                    var td = document.createElement("td");
                    td.setAttribute("style","background:#f3f3f3;border:none");
                    //选择商品高亮显示控制
                    img.onmouseover = function(){ changePicin(td);}
                    img.onmouseout = function(){changePicout(td);}
                    //图片多张
                    var imageData = obj.image_urls;
                    var imagesArray = new Array;
                    imagesArray = imageData.split("#");

                    img.src = "/upload/image/"+imagesArray[0];
                    td.appendChild(img);
                    $("#advice_tr2").append(td);
                    var p1 = document.createElement("p");
                    p1.setAttribute("class","prolist_name");
                    var p2 = document.createElement("p");
                    var a = document.createElement("a");
                    a.setAttribute("href","#");
                    a.innerHTML = obj.name;
                    a.onclick = function(){goodDetail(obj.id);}
                    p1.appendChild(a);
                    var span = document.createElement("span");
                    span.setAttribute("class","money");
                    span.innerHTML = "￥"+obj.price;
                    p2.appendChild(span);
                    td.appendChild(p1).appendChild(p2);
                    $("#advice_tr2").append(td);
                    i++;
                });
            }
        });
        /*获取 最新-1 商品*/
        $.ajax({
            url: '/display/getGoods',
            data: {"keyword":"",type:"1"},
            type: "GET",
            dataType: "json",
            success: function (data) {
                alert("return > 最新 > " + data.data.count);
                var i=1;
                $.each(data.data.list, function (idx, obj) {
                    //显示4条数据
                    if(i==5)
                    {
                        return false;
                    }
                    var img = document.createElement("img");
                    img.setAttribute("alt","没有数据");
                    var td = document.createElement("td");
                    td.setAttribute("style","background:#f3f3f3;border:none");
                    //选择商品高亮显示控制
                    img.onmouseover = function(){ changePicin(td);}
                    img.onmouseout = function(){changePicout(td);}
                    //图片多张
                    var imageData = obj.image_urls;
                    var imagesArray = new Array;
                    imagesArray = imageData.split("#");

                    img.src = "/upload/image/"+imagesArray[0];
                    td.appendChild(img);
                    $("#advice_tr1").append(td);
                    var p1 = document.createElement("p");
                    p1.setAttribute("class","prolist_name");
                    var p2 = document.createElement("p");
                    var a = document.createElement("a");
                    a.setAttribute("href","#");
                    a.innerHTML = obj.name;
                    a.onclick = function(){goodDetail(obj.id);}
                    p1.appendChild(a);
                    var span = document.createElement("span");
                    span.setAttribute("class","money");
                    span.innerHTML = "￥"+obj.price;
                    p2.appendChild(span);
                    td.appendChild(p1).appendChild(p2);
                    $("#advice_tr1").append(td);
                    i++;
                });
            }
        });


        $("img").lazyload({
            effect: "fadeIn",
            container: $("body")
        });
        $("#jdtslide").KinSlideshow({
            moveStyle: "left",
            intervalTime: 5,
            mouseEvent: "mouseover",
            titleBar: {"titleBar_bgColor": ""},
            titleFont: {TitleFont_size: 14, TitleFont_color: "#ffffff"}
        });


    }
/*topSearch 搜索商品*/
function topSearch(){
    alert("topSearch")
    var keyword = $("#topSearch").val();
    var pageNo = $("#pageNo").val();
    var pageSize = $("#pageSize").val();

    $.ajax({
        url: '/display/getGoods',
        data: {"keyword":keyword,type:"","pageNo":pageNo,"pageSize":pageSize},
        type: "GET",
        dataType: "json",
        success: function (data) {
            alert("return > " + data);
            $("#topSearch").val("keyword");

        }
    });
}


//用户承诺书
    function promise() {
        $.layer({
            type: 2,
            title: '承诺书',
            maxmin: true,
            shadeClose: true, //开启点击遮罩关闭层
            area: ['600px', '480px'],
            offset: ['100px', ''],
            iframe: {src: './promise.html'}
        });
    }
